<?php

class Helper_Year {
    public static function getyear() {
		$year = date('Y',time());
		$arr = array();
		for($i=$year+1;$i>$year-5;$i--){
			$arr[$i] = $i."年";
		}
		return $arr;
    }
	/**
	 * 截取中文字符UTF8
	 *
 	 * @param string $str
	 * @param int $len
	 * @param string $padstr
	 * @return string
	 */
	public static function subcnstr($str,$len,$padstr="......"){
		for($i=0;$i<$len;$i++){
			$temp_str=substr($str,0,1);
			if(ord($temp_str) > 127){
				$i++;
				if($i<$len){
					$new_str[]=substr($str,0,3);
					$str=substr($str,3);
				}
			}else{
				$new_str[]=substr($str,0,1);
				$str=substr($str,1);
			}
		}
		$length = strlen($str);
		if($length>$len) $new_str[] = $padstr;
		return join($new_str);
	}
	
}

